//
//  BaoJiaGoodsInforTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/11.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "BaoJiaGoodsInforTableViewCell.h"

@interface BaoJiaGoodsInforTableViewCell ()
@property(nonatomic,strong) GLGWLabel * stellNameLabel;
@property(nonatomic,strong) GLGWLabel * weightLabel;
@property(nonatomic,strong) GLGWLabel * specLabel;
@property(nonatomic,strong) GLGWLabel * maxPiceLabel;

@property(nonatomic,strong) GLGWImageView * goodsPicImageView;
@property(nonatomic,strong) GLGWLabel * titleLabel;
@property(nonatomic,strong) GLGWLabel * gSpecLabel;
@property(nonatomic,strong) GLGWLabel * warehouseLabel;
@property(nonatomic,strong) GLGWLabel * companyLabel;
@property(nonatomic,strong) GLGWLabel * picLabel;


@end

@implementation BaoJiaGoodsInforTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.stellNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:self.contentView];
        self.stellNameLabel.text = @"三级螺纹钢";
        [self.stellNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        //
        self.weightLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:self.contentView];
        self.weightLabel.text = @"50吨";
        self.weightLabel.textAlignment = NSTextAlignmentRight;
        [self.weightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(21));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        [self.stellNameLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.weightLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        //
        self.specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:self.contentView];
        self.specLabel.text = @"HRB400E 400*300 河钢";
        [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel);
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        self.maxPiceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:self.contentView];
        self.maxPiceLabel.text = @"最高5000元/吨";
        self.maxPiceLabel.textAlignment = NSTextAlignmentRight;
        [self.maxPiceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self.weightLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(6));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        [self.specLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.maxPiceLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        //
        GLGWView * garyBankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        garyBankgroundView.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
        garyBankgroundView.layer.cornerRadius = 3.0;
        garyBankgroundView.layer.masksToBounds = YES;
        [garyBankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(16));
        }];
        //
        GLGWLabel * seleGoodsLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:garyBankgroundView];
        seleGoodsLabel.text = @"选择我的店铺中对应的商品";
        [seleGoodsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(garyBankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(garyBankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(12));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        GLGWButton * pushBut = [[GLGWButton alloc] initWithTitleLableFontType:SYSTEMFONT(14) titleColor:[UIColor colorWithHexString:@"#999999"] inSuperView:garyBankgroundView];
        pushBut.title = @"请选择";
        [pushBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(garyBankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(garyBankgroundView);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(44)));
        }];
        [pushBut addTarget:self action:@selector(selectGoodsAction) forControlEvents:UIControlEventTouchUpInside];
        //
        self.goodsPicImageView = [[GLGWImageView alloc] initInSuperView:garyBankgroundView];
        self.goodsPicImageView.backgroundColor = kRandomColor;
        [self.goodsPicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(garyBankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(garyBankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(47));
//            make.bottom.equalTo(garyBankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(15));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(90)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(90)));
        }];
        //
        self.titleLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:garyBankgroundView];
        self.titleLabel.text = @"三级螺纹钢 HRB400E 河钢";
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsPicImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(garyBankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(44));
            make.right.equalTo(garyBankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        self.warehouseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:garyBankgroundView];
        self.warehouseLabel.text = @"北京京南国储库";
        self.warehouseLabel.textAlignment = NSTextAlignmentLeft;
        [self.warehouseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
            make.right.equalTo(garyBankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        self.gSpecLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:garyBankgroundView];
        self.gSpecLabel.text = @"φ6*12";
        [self.gSpecLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsPicImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.titleLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.right.equalTo(self.warehouseLabel.mas_left).offset(-kHeightProportion_In_iPhoneTriploid(10));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        
        [self.gSpecLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
        [self.warehouseLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh) forAxis:(UILayoutConstraintAxisHorizontal)];
        //
        GLGWLabel * tongbuLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:garyBankgroundView];
        tongbuLabel.text = @"同步自";
        [tongbuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsPicImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.gSpecLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        self.companyLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:kColor_Rule_Yellow inSuperView:garyBankgroundView];
        NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
        NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:@"北京泽人合有限公司" attributes:attribtDic];
        self.companyLabel.attributedText = attribtStr;
        [self.companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(tongbuLabel.mas_right).offset(0);
            make.top.height.equalTo(tongbuLabel);
            make.right.equalTo(garyBankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        self.picLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#FF374F"] inSuperView:garyBankgroundView];
        self.picLabel.text = @"¥3845/吨";
        [self.picLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.goodsPicImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.companyLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
    }
    return self;
}

-(void)selectGoodsAction{
    if (self.Block_PushSelectGoods) {
        self.Block_PushSelectGoods();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
